package main

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func partitionLabels(s string) []int {
	lastPos := make(map[byte]int)
	for i, c := range s {
		lastPos[byte(c)] = i
	}
	var result []int
	start := 0
	end := 0
	for i, c := range s {
		c := byte(c)
		lastC := lastPos[c]
		if lastC > end {
			end = lastC
		}
		if i == end {
			result = append(result, end - start + 1)
			start = i+1
		}
	} 
	return result
}

func main() {
	ret := partitionLabels("ababcbacadefegdehijhklij")
	println(ret)
}